<div class="layui-tab layui-tab-brief">
	<ul class="layui-tab-title">
		<li class="layui-this"><a href="#">客户管理</a></li>
		<li><a href="__APP__/{$Request.controller}/tongji.html">统计工具</a></li>
	</ul>
	<div class="layui-tab-content page-tab-content">
		<div class="layui-btn-group">
			<a href="__APP__/{$Request.controller}/add.html" class="layui-btn layui-btn-primary"><i class="layui-icon layui-icon-add-1"></i>添加</a>
			<a href="__APP__/{$Request.controller}/del.html" class="layui-btn layui-btn-primary confirm ajax-btn"><i class="layui-icon layui-icon-close"></i>删除</a>
			<a href="javascript:;" class="layui-btn layui-btn-primary" id="export"><i class="layui-icon layui-icon-chart"></i>导出利润表</a>
			<a href="__APP__/{$Request.controller}/export_all_data.html" class="layui-btn layui-btn-primary" id="export"><i class="layui-icon layui-icon-chart"></i>导出全部数据</a>
		</div>
		<div class="page-filter layui-form fr">
			<div class="layui-inline">{Html:select name="step" options=":LinkageList('BorrowStep')" first="--状态--"}</div>
				<div class="layui-input-inline">
					<input type="text" name="date" placeholder="请选择时间范围" class="layui-input" value="{:input('date')}" id="range">
				</div>
			<div class="layui-inline"><input type="text" name="keywords" lay-verify="required" placeholder="请输入关键词搜索" autocomplete="off" class="layui-input" value="{:input('keywords')}"><button class="layui-icon">&#xe615;</button>
			</div>
		</div>
		<table class="layui-table" id="Data" lay-filter="Data"></table>
	</div>
</div>
<script type="text/html" id="stepTpl">
    {{#  
        var fn = function(){
            return '<span id="Step'+d.id+'">'+BorrowStep[d.step]+'</span>';
        }; 
    }}
    {{ fn() }}
</script>
<script type="text/html" id="txrqTpl">
    {{#  
        var fn = function(){
            return d.step=="c" ? (d.remind_time=="{:date('Y-m-d')}" ? "今天到期" : d.remind_time) : '';
        }; 
    }}
    {{ fn() }}
</script>
<script type="text/html" id="gpsTpl">
    {{#  if(d.gps && (d.gps[0] || d.gps[1])){ }}
        已安装
    {{#  }else{  }}
        未安装
    {{#  } }}  
</script>
<script type="text/html" id="ToolBarTpl">
    <div class="layui-btn-group">
    <a href="__APP__/{$Request.controller}/edit/id/{{d.id}}.html" class="layui-btn layui-btn-primary layui-btn-sm" title="编辑"><i class="layui-icon layui-icon-edit"></i></a>
    <a data-href="__APP__/{$Request.controller}/export_loan_doc/id/{{d.id}}.html" class="layui-btn layui-btn-primary layui-btn-sm popen" title="导出借款协议"><i class="layui-icon layui-icon-file"></i></a>
    <a href="__APP__/{$Request.controller}/edit/id/{{d.id}}.html#Attach" class="layui-btn layui-btn-primary layui-btn-sm" title="附件"><i class="layui-icon layui-icon-picture-fine"></i></a>
    <a data-href="__APP__/{$Request.controller}/repay/id/{{d.id}}.html" class="layui-btn layui-btn-primary layui-btn-sm popen" title="还款计划"><i class="layui-icon layui-icon-date"></i></a>
    </div>
</script>
<div type="text/html" id="dateTpl" style="display:none;position:absolute;"></div>
<div class="layui-form-select spaceClose" id="ChangeStepTpl" style="width:100px;position:absolute;">
	<dl class="layui-anim layui-anim-upbit">
		{volist name=":LinkageList('BorrowStep')" id="stvo"}
		<dd lay-value="{$key}">{$stvo}</dd>
		{/volist}
	</dl>
</div>
<div id="test-n1" style="display: none;">
	
</div>
<script type="text/javascript">
	var BorrowStepJson = '{:json_encode(LinkageList("BorrowStep"))}';
    layui.use(['{$Request.controller}','layer','jquery','laydate'],function(){
		var a=layui.{$Request.controller},
			laydate=layui.laydate,
			layer=layui.layer,
			$=layui.jquery;
		a.index();
		laydate.render({ elem: '#range',type: 'month'});
		var l= null;
		//直接嵌套显示
		laydate.render({ elem: '#test-n1',position: 'static' ,type: 'month',done: function(value, adate, endDate){
			$.post('/loan/export',{ date:value },function(json){
				if(json.code){
					window.location.href= json.url;
				}else{
					layer.msg(json.msg);
				}
			},'json');
		}});
		$('#export').click(function(event) {
			l= layer.open({  type: 1,  content: $('#test-n1')});
		});
    });
</script>